package com.lp.model.config;

import lombok.Data;

@Data
public class AppResult {

    private Integer code;
    private String msg;
    private Object data;

    public static AppResult success(CodeMsg codeMsg, Object data) {
        AppResult appResult = new AppResult();
        appResult.setCode(codeMsg.getCode());
        appResult.setMsg(codeMsg.getMsg());
        appResult.setData(data);
        return appResult;
    }
    public static AppResult success(CodeMsg codeMsg) {
        AppResult appResult = new AppResult();
        appResult.setCode(codeMsg.getCode());
        appResult.setMsg(codeMsg.getMsg());
        return appResult;
    }
    public static AppResult success(Object data) {
        AppResult appResult = new AppResult();
        appResult.setCode(CodeMsg.SUCCESS.getCode());
        appResult.setMsg(CodeMsg.SUCCESS.getMsg());
        appResult.setData(data);
        return appResult;
    }

    public static AppResult success() {
        AppResult appResult = new AppResult();
        appResult.setCode(CodeMsg.SUCCESS.getCode());
        appResult.setMsg(CodeMsg.SUCCESS.getMsg());
        return appResult;
    }

    public static AppResult success(String msg) {
        AppResult appResult = new AppResult();
        appResult.setCode(CodeMsg.SUCCESS.getCode());
        appResult.setMsg(msg);
        return appResult;
    }

    public static AppResult fail(CodeMsg codeMsg, Object data) {
        AppResult appResult = new AppResult();
        appResult.setCode(codeMsg.getCode());
        appResult.setMsg(codeMsg.getMsg());
        appResult.setData(data);
        return appResult;
    }
    public static AppResult fail(CodeMsg codeMsg) {
        AppResult appResult = new AppResult();
        appResult.setCode(codeMsg.getCode());
        appResult.setMsg(codeMsg.getMsg());
        return appResult;
    }
    public static AppResult fail(Object data) {
        AppResult appResult = new AppResult();
        appResult.setCode(CodeMsg.FAIL.getCode());
        appResult.setMsg(CodeMsg.FAIL.getMsg());
        appResult.setData(data);
        return appResult;
    }

    public static AppResult fail(String msg) {
        AppResult appResult = new AppResult();
        appResult.setCode(CodeMsg.FAIL.getCode());
        appResult.setMsg(msg);
        return appResult;
    }


}
